﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using CRM.Entity;
using CRM.BLL;
using DP.Web.UI;
using DP.Web.UI.Controls;
using DP.Common;

namespace CRM.Web.FaqManage
{
    public partial class FaqRightContent : Common.PageBase
    {
        private UserLoginInfo _loginInfo;
        T_FAQ_SRC_BLL sBll = new T_FAQ_SRC_BLL();
        protected override void OnInit(EventArgs e)
        {
            base.VerificationRight = false;
            base.OnInit(e);
            UserLoginInfo.CheckLoginInfo();
            _loginInfo = UserLoginInfo.GetLoginInfo();
            PageHelper.SetPrePageUrl(this.Page);
            PageHelper.SetGoBackUrl(this.Page, btnCancel, StaticConstant.NotBackUrl);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //ddlSRCTYPEBinding();
                pageDataInit();

            }
        }

        private void ddlSRCTYPEBinding()
        {
            
        }

        private void pageDataInit()
        {
            T_FAQ_SRC_Entity entity = new T_FAQ_SRC_Entity();
            entity = sBll.GetEntity("SRCID", PageHelper.GetQueryString(this.Page, "SRCID"));
            PageHelper.SetControlValue(this.Page, entity);
            hlSRCIMGLINK.Text = entity.SRCIMGLINK;
            hlSRCIMGLINK.NavigateUrl = entity.SRCIMGLINK;
            hlSRCTARGETURL.Text = entity.SRCTARGETURL;
            hlSRCTARGETURL.NavigateUrl = entity.SRCTARGETURL;
            HyperLink hl = new HyperLink();
            if (!String.IsNullOrEmpty(entity.ATTACHFILE))
            {
                string[] attachfiles = entity.ATTACHFILE.Split(';');
                for (int i = 0; i < attachfiles.Length; i++)
                {
                    hl = new HyperLink();
                    hl.ID = "AttachFile" + i.ToString()+"   ";
                    hl.Text = GetFileName(attachfiles[i].ToString());
                    hl.NavigateUrl = attachfiles[i].ToString();
                    plATTACHFILE.Controls.Add(hl);
                }   
            }
            else
                hl.Visible = false;
        }

        private string GetFileName(string input)
        {
            return input.Substring(input.LastIndexOf("\\") + 1);
        }
    }
}
